/*
 * SelectScheduleTypeDialog.java
 *
 * Created on 6 de abril de 2009, 15:44
 */

package ubadbtools.deadlockAnalyzer.gui.forms;

import java.awt.Frame;
import javax.swing.GroupLayout;
import javax.swing.JComponent;
import javax.swing.LayoutStyle;

import ubadbtools.deadlockAnalyzer.common.DeadlockModelType;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
@SuppressWarnings("serial")
public class SelectDeadlockModelTypeDialog extends javax.swing.JDialog {
    
    private DeadlockModelType type;
    
    /** Creates new form SelectScheduleTypeDialog */
    public SelectDeadlockModelTypeDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        type = null;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        GroupLayout jPanel1Layout = new GroupLayout((JComponent)jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        rbPrevention = new javax.swing.JRadioButton();
        reDetection = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jLabel1.setText("Seleccione el modelo de deadlock"); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        buttonGroup1.add(rbPrevention);
        rbPrevention.setSelected(true);
        rbPrevention.setText("Prevención"); // NOI18N
        rbPrevention.setName("rbPrevention"); // NOI18N

        buttonGroup1.add(reDetection);
        reDetection.setText("Detección"); // NOI18N
        reDetection.setName("reDetection"); // NOI18N
        jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup()
        	.addContainerGap()
        	.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        	    .addComponent(reDetection)
        	    .addComponent(rbPrevention))
        	.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup()
        	.addGap(16, 16, 16)
        	.addComponent(rbPrevention)
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addComponent(reDetection)
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE));

        jButton1.setText("Aceptar"); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setVerticalGroup(layout.createSequentialGroup()
        	.addContainerGap()
        	.addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, GroupLayout.PREFERRED_SIZE)
        	.addComponent(jButton1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	.addContainerGap(18, Short.MAX_VALUE));
        layout.setHorizontalGroup(layout.createSequentialGroup()
        	.addContainerGap(46, 46)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(layout.createSequentialGroup()
        	        .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	        .addGap(0, 0, Short.MAX_VALUE))
        	    .addGroup(layout.createSequentialGroup()
        	        .addGap(38)
        	        .addGroup(layout.createParallelGroup()
        	            .addGroup(layout.createSequentialGroup()
        	                .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
        	                .addGap(0, 0, Short.MAX_VALUE))
        	            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                .addGap(21)
        	                .addComponent(jButton1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                .addGap(0, 24, Short.MAX_VALUE)))
        	        .addGap(41)))
        	.addContainerGap(33, 33));

        pack();
    }//GEN-END:initComponents

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        if(rbPrevention.isSelected())
        {
            this.type = DeadlockModelType.PREVENTION;
        }
        else if(reDetection.isSelected())
        {
            this.type = DeadlockModelType.DETECTION;
        }

        this.setVisible(false);
    }//GEN-LAST:event_jButton1MouseClicked
    
    public static DeadlockModelType showDialog(Frame parent)
    {
        SelectDeadlockModelTypeDialog dialog = new SelectDeadlockModelTypeDialog(parent, true);
        dialog.setVisible(true);
        
        return dialog.type;
    }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton reDetection;
    private javax.swing.JRadioButton rbPrevention;
    // End of variables declaration//GEN-END:variables
    
}
